<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>流程控制</title>
</head>
<body>
    <input type="password" name="pass" />
    <span id="msg"></span>
</body>
</html>
<script>
    // let state = false;
    // if(state){
    //     console.log('表达式成立')
    // }

    //如果只有一条代码块，可以不用写{}
    // let state = false;
    // if(state) console.log('表达式成立')
    // console.log('一直现实的内容')

    let input = document.querySelector("[name='pass']");
    input.addEventListener('keyup',function(){
        let length = this.value.trim().length;
        let msg = '';
        if(length > 10){
            msg = '密码已经无敌了';
        }else if(length >= 6){
            msg = '中级安全密码';
        }else if(length == 0){
            msg = '请输入密码';
        }
        else if(length <6){
            msg = '密码太危险了';
        }
        document.querySelector("#msg").innerHTML = msg;
    });
</script>